import { Node } from "cc";
import { ecs } from "db://app-game/libs/ecs/ECS";
import { Circle } from "db://app-game/libs/math/auad-tree/Circle";
import { QuadTree } from "db://app-game/libs/math/auad-tree/QuadTree";
import { Rectangle } from "db://app-game/libs/math/auad-tree/Rectangle";

export interface GroupType {
  name: string;
  monitorNode: Node;
}

export interface QueryParams {
  name: string;
  circle: Circle<{ node: Node }>;
}

/** 监视器组件 */
@ecs.register("MonitorGroup")
export class MonitorGroupComp extends ecs.Comp {
  _group: GroupType[] = [];

  /** 监视组 */
  get group(): GroupType[] {
    return this._group;
  }

  set group(monitorGroup: GroupType[]) {
    monitorGroup.forEach((item) => {
      this.monitorNodes[item.name] = item.monitorNode;
    });
    this._group = monitorGroup;
  }

  /** 检测四叉树组 */
  quadTreeObj: {
    [key: string]: QuadTree<Circle<{ node: Node }> | Rectangle<{ node: Node }>>;
  } = {};

  /** 监视节点 */
  monitorNodes: { [key: string]: Node } = {};

  reset(entity: ecs.Entity): void {}
}
